home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!marnold
- From: marnold@netcom.com (Matt Arnold)
- Subject: Re: forward referencing in Borland 4.52
- Message-ID: <marnoldDLD9nC.18w@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <4dkfk2$e4v@cloner3.netcom.com>
- Date: Thu, 18 Jan 1996 07:47:36 GMT
- Sender: marnold@netcom9.netcom.com
-
- regmia@ix.netcom.com writes:
-
-
-
- >Does anyone know how to CORRECTLY create a forward reference to
- >class.
-
- >For those of you who may not understand what I am referring to:
-
- >Forward referencing of a class means to declare a variable of a class
- >type and be able to use that variable BEFORE the class is actually
- >defined.
-
- A follow up to my previous post... The original poster should note
- that forward referencing only allows one to DECLARE variables of the
- forward-referenced class (and you are also limited to pointer and
- references variables at that!). You can not "use" those variables
- (call members, etc.) until the compiler has seen the class declaration
- as normal.
-
- You assumption about what forward referencing above allows is only
- half correct. Think about it, if the compiler has not seen a
- declaration of the class in question, there is no way it can parse
- code refering to members of that class! But, there is no trouble
- parsing code that declares pointers/references to the unseen class
- since the size (for one thing) of the storage for such variables are
- already known to the compiler. This is all that forward-referencing
- gives you---the ability to declare pointers and references to an as-
- yet-unseen class.
-
- Anyway, the limitations of forward referencing should not come as a
- surprise---C works is a similar way when you forward-declare structs.
-
- Regards,
- -------------------------------------------------------------------------
- Matt Arnold | | ||| | |||| | | | || ||
- marnold@netcom.com | | ||| | |||| | | | || ||
- Boston, MA | 0 | ||| | |||| | | | || ||
- 617.389.7384 (h) 617.576.2760 (w) | | ||| | |||| | | | || ||
- C++, MIDI, Win32/95 developer | | ||| 4 3 1 0 8 3 || ||
- -------------------------------------------------------------------------
-